<template>
  <div class="dragArea">
    <div class="sortBase">
      <div class="topMax">强</div>
      <div class="sortNum">
        <div class="sortItem">1</div>
        <div class="sortItem">2</div>
        <div class="sortItem">3</div>
        <div class="sortItem">4</div>
        <div class="sortItem">5</div>
        <div class="sortItem">6</div>
      </div>
      <div class="bottomMin">弱</div>
    </div>
    <!-- 拖拽进入的区域 -->
    <div class="dragInArea"
      @drop="drop"
      @dragover.prevent
    >
      <div 
        v-for="(item, index) of dropList" 
        :key="index" 
        class="inItem" 
        v-dragging="{ item: item, list: dropList, group: 'qusList' }" 
        @drop="drop" 
        @dragover.prevent>
        <span>{{ item.nm }}</span>
        <img src="../../../assets/icon_drag.png" alt="">
      </div>
    </div>
    <div class="dragOutList">
      <div 
        v-for="(item, index) of dragList" 
        :key="index" 
        class="outItem"
        v-dragging="{ item: item, list: dragList, group: 'ites' }"
        :draggable="true"
        @dragstart="dragstart($event, item)"
        @dragend="dragend"
      >
        <span>{{ item.nm }}</span>
        <img src="../../../assets/icon_drag.png" alt="">
      </div>
    </div>
  </div>
</template>

<script>
  export default {
    name: 'dragable',
    props: {
      dragList: Array,
      dropList: Array
    },
    data() {
      return {
        changeObj: {},
        hasDrop: false
      }
    },
    methods: {
      dragstart(event, item) {
        this.changeObj = item
      },
      drop(event) {
        this.hasDrop = true
        this.$emit('handleDrop', this.changeObj)
      },
      dragend() {
        if (this.hasDrop) {
          this.$emit('handleDragend', this.changeObj)
          this.hasDrop = false
        }
      },
    }
  }

</script>

<style lang="less" scoped>
  .dragArea {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    .sortBase {
      display: flex;
      justify-content: flex-start;
      align-items: center;
      flex-direction: column;
      margin-right: 33px;
      .topMax {
        color: #FF8A00;
        font-size: 18px;
        line-height: 33px;
        margin-bottom: 16px;
      }
      .sortNum {
        width:24px;
        height:372px;
        background:rgba(255,255,255,1) linear-gradient(360deg,rgba(255,138,0,0.3) 0%,rgba(255,138,0,1) 100%);
        border-radius:12px;
        display: flex;
        justify-content: flex-start;
        flex-direction: column;
        align-items: center;
        padding-top: 18px;
        margin-bottom: 16px;
        .sortItem {
          color: #fff;
          font-size: 18px;
          line-height: 18px;
          margin-bottom: 44px;
        }
        .sortItem:last-child {
          margin-bottom: 0;
        }
      }
      .bottomMin {
        color: #B8BCBF;
        font-size: 18px;
        line-height: 33px;
      }
    }
    .dragInArea {
      width: 360px;
      height: 372px;
      border-radius: 4px;
      border: 1px solid #EBECED;
      margin-right: 16px;
      .inItem {
        width: 100%;
        height: 62px;
        padding: 10px 24px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        border-bottom: 1px solid #EBECED;
        cursor: pointer;
        span {
          color: #222;
          font-size: 16px;
        }
        img {
          width: 24px;
          height: 24px;
        }
      }
    }
    .dragOutList {
      width: 360px;
      height: 372px;
      .outItem {
        width: 360px;
        height: 54px;
        margin-bottom: 8px;
        background: #FAFAFA;
        border-radius: 4px;
        padding: 10px 24px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        border: 1px solid transparent;
        cursor: pointer;
        span {
          color: #222;
          font-size: 16px;
        }
        img {
          width: 24px;
          height: 24px;
        }
      }
      .outItem:hover {
        border-color: #FF8A00;
        background: #fff;
      }
    }
  }
</style>
